
/*!
 * ksp(knowledge shared platform) project common function javascript v0.1
 *
 * Includes jquery.js v1.11.3
 * 
 * Author : HLM
 * Date: 2018-08-25
 */

	
	/* 获取cookie */
	function getCookie(token) {
		var cookies = document.cookie;
		var arrCookie = document.cookie.split(";");
		for (var i = 0; i < arrCookie.length; i++) {
			var arr = arrCookie[i].split("=");
			if (token == arr[0]) {
				return arr[1];
			}

		}
	}
	
	/* 用户退出 */
	function usrQuit() {
		$.ajax({
			url : "/ksp/usr/KSPU04"
			,type : "post"
			,dataType : "json"
			,cache : false
			,success : function(res) {
				var cod = res.cod;
				if (cod == "200") {
					window.location.href="/ksp";
				}
			}
		});
	}
	
	function getUrlPam(name) {
		var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
		var str = window.location.search.substr(1);
		var r = window.location.search.substr(1).match(reg);
		if (r != null) {
			var str = unescape(r[2]);
			return str;
		}
		return null;
	}
	
	
	/*初始化导航栏*/
	function iniNar() {
		var req = {
			"COO_TKN" : getCookie("COO_TKN")
		};
		var narHtml = '' 
				+ '<ul class="layui-nav layui-bg-cyan" id="nav">'
				+ '<li class="layui-nav-item" id="ksp">'
				+ '	<a href="/ksp" style="front-size:larger">首页</a>'
				+ '</li>' 
				+ '<li class="layui-nav-item" id="tsklst">'
				+ '	<a href="/ksp/p/tsk/tsklst">问题反馈</a>' + '</li>'
				+ '<li class="layui-nav-item" id="artlst">'
				+ '	<a href="/ksp/p/art/artlst">知识分享</a>' + '</li>'
				+ '<li class="layui-nav-item" id="verdes">'
				+ '	<a href="/ksp/p/rls/verdes">版本发布</a>' + '</li>';
		$.ajax({
			url : "/ksp/usr/KSPU02",
			type : "POST",
			dataType : "json",
			data : req,
			success : function(data) {
				if (data.cod == "400") {
					//alert(data.msg);
					narHtml += '' + '<li class="layui-nav-item" id="verdes">'
							+ '	<a href="/ksp/p/usr/usrlgn">登录</a>' + '</li></ul>';
				} else if (data.cod == "200") {
					var curUsr = eval(data.jdt);
					narHtml += '' + '<li class="layui-nav-item" id="verdes">'
							+ '	<a href="#">' + curUsr[0].USR_OAM + '</a>'
							+ '</li></ul>';
				}
				$("#navDiv").html(narHtml);
			}
		});
	}
	
